package com.hc.baselibray.navigationBar;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import com.example.baselibrary.R;

public class DefaultNavigationBar extends AbsNavigationBar<DefaultNavigationBar.Builder.DefaultNavigationParams>{
    public DefaultNavigationBar(DefaultNavigationBar.Builder.DefaultNavigationParams mParams) {
        super(mParams);
    }

    @Override
    public int bindLayoutId() {
        return R.layout.title_bar;
    }

    @Override
    public void applyView() {
    //绑定效果
        setText(R.id.rightTxt,getmParams().mRightTitle);
        setText(R.id.title,getmParams().mTitle);
        setVisible(R.id.back,getmParams().showBack);
        setOnClickListener(R.id.rightTxt,getmParams().mRightOnclickListener);
    }
    public static  class  Builder extends  AbsNavigationBar.Builder{
        DefaultNavigationParams P;
        public Builder(Context context, ViewGroup parent) {
            super(context, parent);
            P=new DefaultNavigationParams(context,parent);
        }
        public Builder(Context context) {
            super(context);
            P=new DefaultNavigationParams(context);
        }

        @Override
        public DefaultNavigationBar builder() {
            DefaultNavigationBar navigationBar=new DefaultNavigationBar(P);
            return navigationBar;
        }
        //设置标题
        public  DefaultNavigationBar.Builder setTitle(String title){
            P.mTitle=title;
            return this;
        }
        //设置右边边文字
        public  DefaultNavigationBar.Builder setRightTitle(String title){
            P.mRightTitle=title;
            return this;
        }
        //文字点击
        public  DefaultNavigationBar.Builder setRightOnclickLister(View.OnClickListener listener){
            P.mRightOnclickListener=listener;
            return this;
        }
        //设置右边图标
        public  AbsNavigationBar.Builder setRightIcon(int res){
            P.mRightRes=res;
            return this;
        }

        //图标点击
        public  AbsNavigationBar.Builder setRightIconOnclickLister(View.OnClickListener listener){
            P.mRightIconOnclickListener=listener;
            return this;
        }

        public  static  class  DefaultNavigationParams extends  AbsNavigationBar.Builder.AbsNavigationParams{
            public  String mTitle;
            public  String mRightTitle;
            public  int mRightRes;
            public View.OnClickListener mRightOnclickListener;
            public View.OnClickListener mRightIconOnclickListener;
            public boolean showBack=true;
            //所有效果参数
           public DefaultNavigationParams(Context context, ViewGroup parent) {
                super(context, parent);
            }
            public DefaultNavigationParams(Context context) {
                super(context);
            }
        }
    }
}
